#ifndef FS_PROCESS_PERSISTENCE_ASSISTANT_H
#define FS_PROCESS_PERSISTENCE_ASSISTANT_H

#include <ipersistenceassistant.h>
#include <mimetype.h>

namespace swp
{

class FsProcessPersistenceAssistant : public core::IPersistenceAssistant
{
public:
    FsProcessPersistenceAssistant(const core::MimeType& mimeType);
    ~FsProcessPersistenceAssistant();

    // IPersistenceAssistant
    bool canOpen(const core::MimeType& mimeType) const;
    bool canSave(const core::MimeType& mimeType) const;
    bool isNative(const QSharedPointer<core::IPersistentDocument>&
        document) const;
    bool isNative(const core::MimeType& mimeType) const;
    QString forStorage() const;

    QSharedPointer<core::IDocument> open();
    QSharedPointer<core::IDocument> openFuture();
    QSharedPointer<core::IPersistentDocument> save();

    void closeAndKeepFuture();

    bool createPersistentDocument(const QUrl& url,
        const core::IStorage* storage);

    QSharedPointer<core::IDocument> getDocument() const;
    QSharedPointer<core::IPersistentDocument> getPersistentDocument() const;

protected:
    IPersistenceAssistant* copy() const;

    void setDocument(const QSharedPointer<core::IDocument>& document);
    void setPersistentDocument(
        const QSharedPointer<core::IPersistentDocument>& document);

private:
    QSharedPointer<IPersistenceAssistant> getNativeAssistant(
            const QSharedPointer<core::IDocument>& document) const;
    void findAndAddLinks(const QStringList& linkUrls);

private:
    core::MimeType m_mimeType;
    QSharedPointer<core::IPersistentDocument> m_persistentDocument;
    QSharedPointer<core::IDocument> m_document;
};

} // namespace swp

#endif
